﻿@using MvcApplication.Entity;
@model Post
@{
    ViewBag.Title = Model.ID == 0 ? "新建" : "编辑";
}
<style>
    .cover {
        max-width: 360px;
        max-height: 200px;
    }
</style>
<div ms-controller="post_eidt">
    <div class="am-cf am-padding">
        <div class="am-fl am-cf">
            <strong class="am-text-primary am-text-lg">文章</strong> / 
            <small ms-if="post.ID > 0">编辑</small>
            <small ms-if="post.ID == 0">新建</small>
        </div>
    </div>

    <input id="post_data" type="hidden" value="@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model))"/>
    <input id="category_data" type="hidden" value="@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(ViewBag.Categories))"/>
    <div class="am-g">
        <div class="am-u-sm-12">
            <form class="am-form">
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-12 am-u-md-2 am-text-right">
                        标题
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <input style="width: 101%" type="text" class="am-input-sm" name="title" ms-duplex="post.Title" placeholder="必填，不可重复">
                    </div>
                    <div class="am-u-sm-12 am-u-md-4" style="position: relative;">
                        <div style="height: 100px; position: absolute">
                            @Html.Partial("~/Views/Post/FirstPicture.cshtml")
                        </div>
                    </div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-12 am-u-md-2 am-text-right">类目</div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <select multiple name="categories"
                            id="category_select"
                            data-am-selected="{btnSize: 'sm',searchBox: 1, btnWidth: '101%'}">
                            <option ms-repeat-el="categories" ms-attr-value="el.ID" ms-attr-selected="el.is_checked">{{el.Name}}</option>
                        </select>
                    </div>
                    <div class="am-u-sm-12 am-u-md-4">&nbsp;</div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-12 am-u-md-2 am-text-right">状态</div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <div class="am-form-group" style="margin-bottom: 0;">
                            @foreach (var value in Enum.GetValues(typeof(MvcApplication.Entity.PostStatus)))
                            { 
                                <label class="am-radio-inline">
                                    <input type="radio" name="status" value="@((int)value)" 
                                           data-am-ucheck ms-click="change_status(@((int)value))"/>
                                    @value
                                </label>
                            }
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-4">&nbsp;</div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-12 am-u-md-2 am-text-right">归类</div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <div class="am-form-group" style="margin-bottom: 0;">
                            <label class="am-checkbox-inline">
                                <input type="checkbox" data-am-ucheck ms-duplex-checked="post.IsTop">
                                置顶
                            </label>
                            <label class="am-checkbox-inline">
                                <input type="checkbox" value="" data-am-ucheck ms-duplex-checked="post.IsRecommended">
                                推荐
                            </label>
                            <label class="am-checkbox-inline">
                                <input type="checkbox" value="" data-am-ucheck ms-duplex-checked="post.IsHot">
                                热门
                            </label>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-4">&nbsp;</div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-12 am-u-md-2 am-text-right">其他</div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <a href="###" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0, width: 400, height: 325}">SEO设置</a>
                    </div>
                    <div class="am-u-sm-12 am-u-md-4">&nbsp;</div>
                </div>
                <div style="margin-top: 10px;">&nbsp;</div>
                <div class="am-g am-margin-top-sm">
                    <div class="am-u-sm-12 am-u-md-2 am-text-right admin-form-text">
                        内容
                    </div>
                    <div class="am-u-sm-12 am-u-md-10">
                        <textarea id="detail" name="detail" rows="10" style="width: 100%; height: 535px;" placeholder="">@Html.Raw(Model.Detail)</textarea>
                    </div>
                </div>

                <div class="am-g am-margin-top-sm">
                    <div class="am-u-sm-12 am-u-md-2 am-text-right admin-form-text">
                        &nbsp;
                    </div>
                    <div class="am-u-sm-12 am-u-md-10">
                        <button type="button" ms-click="save_post()" class="am-btn am-btn-primary ">提交保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
@Html.Partial("~/Views/Post/SEODialog.cshtml")

@Scripts.Render("~/Content/kindeditor/kindeditor-all-min.js")
@Scripts.Render("~/Content/kindeditor/lang/zh_CN.js")
@Scripts.Render("~/Content/js/common/file-upload.js")


<script>
    KindEditor.ready(function (K) {
        window.editor = K.create('#detail', {
            width: '101%',
            height: '425px',
            uploadJson: '/image/index',
            items: [
                    'source', 'fullscreen',
                    'fontname', 'fontsize', 'wordpaste', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                    'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                    'insertunorderedlist', '|', 'image', 'multiimage', 'link', 'unlink', 'preview'
            ]
        });
    });
</script>
@Scripts.Render("~/Content/js/post/edit.js")
